package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.CategoryDTO;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface CategoryMapper {


    // 分页查询
    List<Category> findList(CategoryPageQueryDTO dto);

    // 新增分类
    @AutoFill("insert")
    @Insert("insert into category values (null,#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(Category category);

    // 根据id删除分类
    @Delete("delete from category where id=#{id}")
    void deleteById(Long id);

    //修改
    @AutoFill("update")
    void update(Category category);

    // 动态sql
    List<Category> findByStatusAndType(CategoryDTO dto);
}
